<template>
    <div>
        <el-card>
            <h1>这里是子组件</h1>
            <el-input v-model="msg" />
            <el-input v-model="childMsg"></el-input>
            <hr>
            <el-button type="primary" @click="$emit('childClick',childMsg)">来自子组件的点击</el-button>
            <el-button type="primary" @click="sendMsg">发送Child组件的消</el-button>
        </el-card>
    </div>
</template>

<script>
import { ref } from 'vue'
import bus from 'vue3-eventbus'

export default {
    name:'Child',
    props: {
        msg: String
    },
    setup() {
        const childMsg = ref("我是子组件的值");
        const sendMsg = function () {
            bus.emit('getMsg', childMsg.value)
        }
        return {
            childMsg,
            sendMsg
        }
    }
}
</script>

<style scoped></style>